package com.neuedu.nep.controller;

import com.neuedu.nep.base.R;
import com.neuedu.nep.model.GridCity;
import com.neuedu.nep.model.GridProvince;
import com.neuedu.nep.service.CityService;
import com.neuedu.nep.service.ProvinceService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

/**
 * @author 黄宇佳
 * @create 2024-04-10 14:33
 * @description:
 */
@RestController
@CrossOrigin
@RequestMapping("provinceCity")
public class ProvinceCityController {

    @Resource
    private ProvinceService provinceService;

    @Resource
    private CityService cityService;

    @GetMapping("proviceAll")
    public R proviceAll(){
        List<GridProvince> gridProvinces = provinceService.provinceAll();
        return R.ok().setResult("provinces",gridProvinces);
    }

    @GetMapping("cityAll")
    public R cityAll(@RequestParam Integer provinceId){
        List<GridCity> gridCities = cityService.CityAllByProvinceId(provinceId);
        return R.ok().setResult("cities",gridCities);
    }
}
